package com.gitee.elf.core.entity.ai

import com.gitee.elf.api.event.ElfEntitySpawnEvent
import com.gitee.elf.core.entity.AbstractBukkitProxyEntity
import taboolib.common.platform.event.SubscribeEvent
import taboolib.common.platform.function.info
import taboolib.module.ai.addGoalAi
import taboolib.module.ai.clearGoalAi
import taboolib.module.ai.clearTargetAi

object BukkitEntityAi {

    @SubscribeEvent
    fun e(e: ElfEntitySpawnEvent) {
        val entity = e.mapping as? AbstractBukkitProxyEntity<*> ?: return
        entity.ifLivingEntity {
            clearTargetAi()
            clearGoalAi()
            addGoalAi(BukkitFollowAi(e.instance), 1)
            info("添加ai")
        }
    }

}